function binding() {
    if(!validateForm()) return false;
    let pm = {
        //获得openId
        openId:$("input[name=openId]").val(),
        //获得姓名
        person:$("input[name=person]").val(),
        //获得电话
        phone:$("input[name=phone]").val()
    }
    let url = "/wechat/binding";
    //绑定
    $.ajax({
        url:url,
        type:"post",
        data:JSON.stringify(pm),
        contentType:"application/json",
        dataType:"json",
        success:function(data){
            if (data.code === "200") {
                swal("绑定成功!", "请继续操作", "success");
            } else {
                swal(data.message, "请重试", "error");
            }
        }
    });
}

//表单验证
function validateForm() {
    //validate方法参数可选
    return $("#myform").validate({
        rules: {
            openId: {
                required: true//必填
            },
            person: {
                required: true//必填
            },
            phone: {
                required: true//必填
            }
        },
        //错误信息提示
        messages: {
            openId: {
                required: "(必填)"
            },
            person: {
                required: "(必填)"
            },
            phone: {
                required: "(必填)"
            }
        },
    }).form();
}